CREATE TABLE [dbo].[tb_GruposDeIncumbencias]
(
[idGrupoIncumbencia] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Nivel] [int] NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[BajaDeGrupoEnRelacion] ON [dbo].[tb_GruposDeIncumbencias]
FOR DELETE 
AS
SET NOCOUNT ON

/*DECLARE @ID

SELECT @ID = (SELECT IdGrupoIncumbencia FROM DELETED)

DELETE FROM tb_relUnionGSGU WHERE


NOTA: Tengo que chequear que hago con los otros grupos!!!!!

*/

GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[NuevoGrupoEnRelacion] ON [dbo].[tb_GruposDeIncumbencias]
FOR INSERT 
AS

DECLARE @ID INT
/*
SELECT @ID = (SELECT IdGrupoIncumbencia FROM INSERTED)

INSERT INTO tb_RelUnionGSGU(IdGrupoSimple, IdGrupoUnion) VALUES(@ID, @ID)

IF @@Error <> 0
	ROLLBACK

*/
GO
ALTER TABLE [dbo].[tb_GruposDeIncumbencias] ADD CONSTRAINT [PK_tb_GruposDeIncumbencias] PRIMARY KEY CLUSTERED  ([idGrupoIncumbencia]) ON [PRIMARY]
GO
